package com.star.common.email;


import com.star.common.email.config.EmailProperties;

import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * 初始化装载
 *
 * @author zhouhengzhe
 */
public class Initialized {
    private static final AtomicBoolean S_INITIALIZED = new AtomicBoolean(false);

    /**
     * 是否允许初始化
     *
     * @param map email配置
     * @return 返回是/否
     */
    public static boolean allowInit(Map<String, EmailProperties> map) {
        if (!S_INITIALIZED.get()) {
            synchronized (Initialized.class) {
                if (!S_INITIALIZED.get() && map != null && map.size() > 0) {
                    S_INITIALIZED.set(true);
                    return true;
                }
            }
        }
        return false;
    }
}
